using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MyMES.Dto;
using MyMES.IServices.QualityAssurance;
using System.Threading.Tasks;
using VOL.Core.Controllers.Basic;
using VOL.Core.Filters;
using VOL.Core.Utilities.Response;
using VOL.Entity.AttributeManager;
using VOL.Entity.DomainModels.Core;
using VOL.Entity.DomainModels.QualityAssurance;

namespace VOL.WebApi.Controllers.MyMES
{
    /// <summary>
    /// 待检任务管理控制器
    /// </summary>
    [Route("api/WaitTask")]
    [ApiController]
    [AllowAnonymous] // 允许匿名访问
    [PermissionTable(Name = "WaitTask")]
    public class WaitTaskController : ApiBaseController<IWaitTaskService>
    {
        private readonly IWaitTaskService _waitTaskService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="waitTaskService">待检任务服务</param>
        public WaitTaskController(IWaitTaskService waitTaskService)
            : base(waitTaskService)
        {
            _waitTaskService = waitTaskService;
        }

        /// <summary>
        /// 获取待检任务列表
        /// </summary>
        /// <param name="dto">查询参数</param>
        /// <returns>待检任务列表（分页）</returns>
        [HttpPost("GetWaitTask")]
        public async Task<ActionResult> GetWaitTask([FromBody] GetWaitTaskDto dto)
        {
            return Json(await _waitTaskService.GetWaitTask(dto));
        }

        /// <summary>
        /// 根据ID获取待检任务详情
        /// </summary>
        /// <param name="id">待检任务ID</param>
        /// <returns>待检任务详情</returns>
        [HttpGet("GetWaitTaskById/{id}")]
        public async Task<WebResponseContent> GetWaitTaskById(int id)
        {
            return await _waitTaskService.GetWaitTaskById(id);
        }

        /// <summary>
        /// 添加来料检验记录
        /// </summary>
        /// <param name="incominginspection">来料检验实体</param>
        /// <returns>操作结果</returns>
        [HttpPost("AddIncominginspection")]
        public async Task<WebResponseContent> AddIncominginspection([FromBody] Incominginspection incominginspection)
        {
            return await _waitTaskService.AddIncominginspection(incominginspection);
        }
    }
} 